#ifndef __LOGIC_H__
#define __LOGIC_H__

#include <atomic>
#include <queue>
#include <thread>
#include <map>
#include <functional>
#include <memory>

#include <json/json.h>
#include <json/value.h>
#include <json/reader.h>
#include <json/writer.h>

#include "session.h"


using FuncCallBack = std::function<void(Session::ptr session, const uint16_t msg_id, const std::string& msg_data)>;

class Logic 
{
public:
    Logic();
    ~Logic();

    void post_task(Task::ptr task);
    void run();

private:
    void register_callback();
    void hello_world_task(Session::ptr session, const uint16_t msg_id, const std::string& msg_data);

private:
    std::queue<Task::ptr> _task_que;
    std::mutex _task_mutex;
    std::condition_variable _task_cond;
    std::thread _work_thread;
    std::atomic_bool _is_stop;
    std::map<uint16_t, FuncCallBack> _callback;
};


#endif // !__LOGIC_H__
